package leetcode.code2212;

import java.util.Arrays;

import leetcode.IDebug;

public class Solution implements IDebug {

	int[] aliceArrows;
	int max;
	int size = 12;
	int[] ans;

	public int[] maximumBobPoints(int numArrows, int[] aliceArrows) {
		this.aliceArrows = aliceArrows;
		this.max = -1;
		int[] tmp = new int[size];
		this.maximumBobPoints(0, numArrows, tmp, 0);
		return ans;
	}

	private void maximumBobPoints(int index, int numArrows, int[] tmp, int score) {
		if (index == 12) {
			if (score > max) {
				max = score;
				ans = Arrays.copyOf(tmp, 12);
				ans[0] += numArrows;
			}
			return;
		}
		this.maximumBobPoints(index + 1, numArrows, tmp, score);
		int alice = this.aliceArrows[index] + 1;
		if (numArrows >= alice) {
			tmp[index] = alice;
			this.maximumBobPoints(index + 1, numArrows - alice, tmp, score + index);
			tmp[index] = 0;
		}
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
